package com.zhen.controller;

import com.zhen.domain.User;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class User1Controller {

    private static final Log logger = LogFactory.getLog(User1Controller.class);

    @ModelAttribute
    public void userModel(String loginname, String password, Model model){
        logger.info("userModel");
        User user = new User();
        user.setLoginname(loginname);
        user.setPassword(password);
        model.addAttribute("user",user);
    }

    @RequestMapping(value = "/login1")
    public String login(Model model){
        User user = (User) model.asMap().get("user");
        System.out.println(user);
        user.setUsername("测试");
        return "result1";
    }
}
